{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "import glob\n",
    "import pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_idx(lists, flag):\n",
    "    idx = 0\n",
    "    while idx<len(temp) and temp[idx]!=char:\n",
    "        idx+=1\n",
    "    return idx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_char_last_index(strs, char):\n",
    "    temp = strs[::-1]\n",
    "    idx = 0\n",
    "    while idx<len(temp) and temp[idx]!=char:\n",
    "        idx+=1\n",
    "    return (len(temp)-1-idx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "48"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_char_last_index(csv_file_list[0],'.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "class CsvFile:\n",
    "    def __init__(self, file_path):\n",
    "        self.file_path =  file_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solutions:\n",
    "    '''\n",
    "        csv文件处理\n",
    "    '''\n",
    "    def __init__(self, CsvFile):\n",
    "        '''\n",
    "            初始化函数，\n",
    "            属性： CsvFile： CsvFile对象\n",
    "        '''\n",
    "        self.CsvFile =  CsvFile\n",
    "    \n",
    "        \n",
    "    def get_idx(self, flag, lists):\n",
    "        '''\n",
    "            @brief：返回 flag 在lists第一次出现的下标\n",
    "            @param: flag: 待寻找的元素\n",
    "                    lists:集合\n",
    "        '''\n",
    "        idx = 0\n",
    "        while idx<len(temp) and temp[idx]!=char:\n",
    "            idx+=1\n",
    "        return idx\n",
    "    \n",
    "    def get_last_index(self, flag, lists):\n",
    "        '''\n",
    "            获取 flag 在 lists 最后一次出现的下标\n",
    "            思路： 反转字符串后， 寻找第一次出现的下标\n",
    "        '''\n",
    "        temp = strs[::-1]  # 反转字符串\n",
    "        idx = get_idx(self, flag, temp)\n",
    "        return (len(temp)-1-idx)\n",
    "    \n",
    "    def get_id_name(self):\n",
    "        '''\n",
    "            对属性 file_path 处理，得到csv文件对应的股票代码\n",
    "        '''\n",
    "        begin_char = '/'\n",
    "        end_char = '.'\n",
    "        begin_index = get_last_index(self.CsvFile.file_path, \n",
    "                                          begin_char) + 1\n",
    "        end_index = get_last_index(self.CsvFile.file_path,\n",
    "                                        end_char)\n",
    "        return self.CsvFile.file_path[begin_index, end_index]\n",
    "    \n",
    "    \n",
    "    def get_df(self):\n",
    "        '''\n",
    "            通过属性 file_path 处理csv数据，得到 DataFrame\n",
    "        '''\n",
    "        file = pd.read_csv(self.CsvFile.file_path)\n",
    "        df = pd.DataFrame(file)\n",
    "        return df\n",
    "    \n",
    "    def get_df_head_list(self):\n",
    "        '''\n",
    "            无参构造，得到列标题\n",
    "        '''\n",
    "        df = self.get_df()\n",
    "        head_list = df.columns.values.tolist()\n",
    "        return head_list\n",
    "    \n",
    "    def search_equal(self, head, val, show_head_list):\n",
    "        \n",
    "        '''\n",
    "            寻找在 head 这一列中 值为 val的行，显示内容由 show_head_list 决定\n",
    "        '''\n",
    "        #-----------------------------------------\n",
    "        '''\n",
    "        df_head_list = self.get_df_head_list()\n",
    "        head = df_head_list[head_idx]\n",
    "        '''\n",
    "        #-----------------------------------------\n",
    "        df = self.get_df()\n",
    "        return df.loc[ (df[head] == val), \n",
    "                show_head_list]\n",
    "    def search_cmp(self,head, val, show_head_list):\n",
    "        '''\n",
    "            寻找在 head 这一列中 值> val的行，显示内容由 show_head_list 决定\n",
    "        '''\n",
    "        df = self.get_df()\n",
    "        return df.loc[ (df[head] > val), \n",
    "                       show_head_list ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def marge(csv_list, outputfile):\n",
    "    for inputfile in csv_list:\n",
    "        f = open(inputfile, 'r', encoding='gb18030',errors='ignore')\n",
    "        data = pd.read_csv(f,encoding='gb18030')\n",
    "        data.to_csv(outputfile, mode='a', index=False)\n",
    "    print('完成合并')\n",
    " \n",
    " #去重保留一个表头\n",
    "def distinct(file):\n",
    "    df = pd.read_csv(file, header=None)\n",
    "    datalist = df.drop_duplicates()\n",
    "    datalist.to_csv( index=False, header=False)\n",
    "    print('完成去重')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['/home/excel/python_program/data/lab2/data/600519.csv', '/home/excel/python_program/data/lab2/data/000858.csv']\n",
      "完成合并\n",
      "完成去重\n"
     ]
    }
   ],
   "source": [
    "csv_list = glob.glob(os.getcwd()+'/data/*.csv')\n",
    "output_csv_path = 'data/margin.csv'\n",
    "print(csv_list)\n",
    "marge(csv_list, output_csv_path)\n",
    "distinct(output_csv_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** <center>--------------------TEST---------------------</center> **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_path = '/home/excel/python_program/data/lab2/data/margin.csv'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>最高价</th>\n",
       "      <th>最低价</th>\n",
       "      <th>开盘价</th>\n",
       "      <th>前收盘</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>换手率</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-09-21</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1666.8</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1666.66</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1695.0</td>\n",
       "      <td>-28.2</td>\n",
       "      <td>-1.6637</td>\n",
       "      <td>0.1787</td>\n",
       "      <td>2244407</td>\n",
       "      <td>3756765108.0</td>\n",
       "      <td>2093830493040.0</td>\n",
       "      <td>2093830493040.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-09-18</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1695.0</td>\n",
       "      <td>1695.0</td>\n",
       "      <td>1635.01</td>\n",
       "      <td>1665.0</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>24.48</td>\n",
       "      <td>1.4654</td>\n",
       "      <td>0.3757</td>\n",
       "      <td>4720140</td>\n",
       "      <td>7853673241.0</td>\n",
       "      <td>2129255271000.0</td>\n",
       "      <td>2129255271000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-09-17</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>1700.0</td>\n",
       "      <td>1658.0</td>\n",
       "      <td>1700.0</td>\n",
       "      <td>1725.1</td>\n",
       "      <td>-54.58</td>\n",
       "      <td>-3.1639</td>\n",
       "      <td>0.5069</td>\n",
       "      <td>6367985</td>\n",
       "      <td>10683350187.0</td>\n",
       "      <td>2098503548860.0</td>\n",
       "      <td>2098503548860.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-09-16</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1725.1</td>\n",
       "      <td>1764.81</td>\n",
       "      <td>1719.0</td>\n",
       "      <td>1760.0</td>\n",
       "      <td>1760.0</td>\n",
       "      <td>-34.9</td>\n",
       "      <td>-1.983</td>\n",
       "      <td>0.1792</td>\n",
       "      <td>2251598</td>\n",
       "      <td>3916457762.0</td>\n",
       "      <td>2167066824780.0</td>\n",
       "      <td>2167066824780.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-09-15</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1760.0</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1747.75</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1766.0</td>\n",
       "      <td>-6.0</td>\n",
       "      <td>-0.3398</td>\n",
       "      <td>0.1657</td>\n",
       "      <td>2082087</td>\n",
       "      <td>3654872009.0</td>\n",
       "      <td>2210908128000.0</td>\n",
       "      <td>2210908128000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10062</th>\n",
       "      <td>1998-05-04</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>59.02</td>\n",
       "      <td>59.02</td>\n",
       "      <td>55.0</td>\n",
       "      <td>55.1</td>\n",
       "      <td>53.65</td>\n",
       "      <td>5.37</td>\n",
       "      <td>10.0093</td>\n",
       "      <td>6.8347</td>\n",
       "      <td>4920974</td>\n",
       "      <td>285312925.33</td>\n",
       "      <td>18886400000.0</td>\n",
       "      <td>4249440000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10063</th>\n",
       "      <td>1998-04-30</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>53.65</td>\n",
       "      <td>54.2</td>\n",
       "      <td>53.2</td>\n",
       "      <td>53.3</td>\n",
       "      <td>53.3</td>\n",
       "      <td>0.35</td>\n",
       "      <td>0.6567</td>\n",
       "      <td>3.3135</td>\n",
       "      <td>2385686</td>\n",
       "      <td>127942178.11</td>\n",
       "      <td>17168000000.0</td>\n",
       "      <td>3862800000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10064</th>\n",
       "      <td>1998-04-29</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>53.3</td>\n",
       "      <td>54.98</td>\n",
       "      <td>52.9</td>\n",
       "      <td>54.97</td>\n",
       "      <td>54.19</td>\n",
       "      <td>-0.89</td>\n",
       "      <td>-1.6424</td>\n",
       "      <td>4.7128</td>\n",
       "      <td>3393230</td>\n",
       "      <td>181927515.95</td>\n",
       "      <td>17056000000.0</td>\n",
       "      <td>3837600000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10065</th>\n",
       "      <td>1998-04-28</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>54.19</td>\n",
       "      <td>56.5</td>\n",
       "      <td>53.6</td>\n",
       "      <td>54.0</td>\n",
       "      <td>53.57</td>\n",
       "      <td>0.62</td>\n",
       "      <td>1.1574</td>\n",
       "      <td>9.397</td>\n",
       "      <td>6765827</td>\n",
       "      <td>371571836.1</td>\n",
       "      <td>17340800000.0</td>\n",
       "      <td>3901680000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10066</th>\n",
       "      <td>1998-04-27</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>53.57</td>\n",
       "      <td>57.0</td>\n",
       "      <td>29.77</td>\n",
       "      <td>29.77</td>\n",
       "      <td>0.0</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>47.4487</td>\n",
       "      <td>34163076</td>\n",
       "      <td>1846204586.12</td>\n",
       "      <td>17142400000.0</td>\n",
       "      <td>3857040000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10067 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               日期     股票代码     名称      收盘价      最高价      最低价      开盘价  \\\n",
       "0      2020-09-21  '600519   贵州茅台   1666.8  1692.76  1666.66  1692.76   \n",
       "1      2020-09-18  '600519   贵州茅台   1695.0   1695.0  1635.01   1665.0   \n",
       "2      2020-09-17  '600519   贵州茅台  1670.52   1700.0   1658.0   1700.0   \n",
       "3      2020-09-16  '600519   贵州茅台   1725.1  1764.81   1719.0   1760.0   \n",
       "4      2020-09-15  '600519   贵州茅台   1760.0  1769.99  1747.75  1769.99   \n",
       "...           ...      ...    ...      ...      ...      ...      ...   \n",
       "10062  1998-05-04  '000858  五 粮 液    59.02    59.02     55.0     55.1   \n",
       "10063  1998-04-30  '000858  五 粮 液    53.65     54.2     53.2     53.3   \n",
       "10064  1998-04-29  '000858  五 粮 液     53.3    54.98     52.9    54.97   \n",
       "10065  1998-04-28  '000858  五 粮 液    54.19     56.5     53.6     54.0   \n",
       "10066  1998-04-27  '000858  五 粮 液    53.57     57.0    29.77    29.77   \n",
       "\n",
       "           前收盘     涨跌额      涨跌幅      换手率       成交量           成交金额  \\\n",
       "0       1695.0   -28.2  -1.6637   0.1787   2244407   3756765108.0   \n",
       "1      1670.52   24.48   1.4654   0.3757   4720140   7853673241.0   \n",
       "2       1725.1  -54.58  -3.1639   0.5069   6367985  10683350187.0   \n",
       "3       1760.0   -34.9   -1.983   0.1792   2251598   3916457762.0   \n",
       "4       1766.0    -6.0  -0.3398   0.1657   2082087   3654872009.0   \n",
       "...        ...     ...      ...      ...       ...            ...   \n",
       "10062    53.65    5.37  10.0093   6.8347   4920974   285312925.33   \n",
       "10063     53.3    0.35   0.6567   3.3135   2385686   127942178.11   \n",
       "10064    54.19   -0.89  -1.6424   4.7128   3393230   181927515.95   \n",
       "10065    53.57    0.62   1.1574    9.397   6765827    371571836.1   \n",
       "10066      0.0    None     None  47.4487  34163076  1846204586.12   \n",
       "\n",
       "                   总市值             流通市值  \n",
       "0      2093830493040.0  2093830493040.0  \n",
       "1      2129255271000.0  2129255271000.0  \n",
       "2      2098503548860.0  2098503548860.0  \n",
       "3      2167066824780.0  2167066824780.0  \n",
       "4      2210908128000.0  2210908128000.0  \n",
       "...                ...              ...  \n",
       "10062    18886400000.0     4249440000.0  \n",
       "10063    17168000000.0     3862800000.0  \n",
       "10064    17056000000.0     3837600000.0  \n",
       "10065    17340800000.0     3901680000.0  \n",
       "10066    17142400000.0     3857040000.0  \n",
       "\n",
       "[10067 rows x 15 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(pd.read_csv(file_path))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**<center>----------------TEST--------------</center>**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/excel/python_program/data/lab2/data/margin.csv',\n",
       " '/home/excel/python_program/data/lab2/data/600519.csv',\n",
       " '/home/excel/python_program/data/lab2/data/000858.csv']"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csv_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_file_list(path):\n",
    "    '''\n",
    "    给出\n",
    "    '''\n",
    "    # ['600519.csv', '000858.csv']\n",
    "    path_file_short_list = os.listdir(path) \n",
    "    path_file_full_list  = []\n",
    "    for files in path_file_list:\n",
    "        path_file_full = os.path.join(path, files)\n",
    "        path_file_full_list.append(path_file_full)\n",
    "    return path_file_full_list\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "def main():\n",
    "    csv_list = glob.glob(os.getcwd()+'/data/*.csv')\n",
    "    margin_file_path = os.getcwd()+'/data/margin.csv'\n",
    "    if margin_file_path not in csv_list:\n",
    "        output_csv_path = 'data/margin.csv'\n",
    "        marge(csv_list, output_csv_path)\n",
    "        distinct(output_csv_path)\n",
    "        pwd = os.getcwd()+'/data'    # csv文件所在目录\n",
    "        csv_list = glob.glob(os.getcwd()+'/data/*.csv')\n",
    "    print(csv_list)\n",
    "    file = CsvFile(csv_list[0]) # 读取第一个csv文件，新建CsvFile对象，\n",
    "    test = Solutions(file)\n",
    "    show_list = test.get_df_head_list()\n",
    "    pprint.pprint(test.get_df())\n",
    "    print(test.search_equal('日期', '2020-09-17', show_list).head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['/home/excel/python_program/data/lab2/data/margin.csv', '/home/excel/python_program/data/lab2/data/600519.csv', '/home/excel/python_program/data/lab2/data/000858.csv']\n",
      "               日期     股票代码     名称      收盘价      最高价      最低价      开盘价  \\\n",
      "0      2020-09-21  '600519   贵州茅台   1666.8  1692.76  1666.66  1692.76   \n",
      "1      2020-09-18  '600519   贵州茅台   1695.0   1695.0  1635.01   1665.0   \n",
      "2      2020-09-17  '600519   贵州茅台  1670.52   1700.0   1658.0   1700.0   \n",
      "3      2020-09-16  '600519   贵州茅台   1725.1  1764.81   1719.0   1760.0   \n",
      "4      2020-09-15  '600519   贵州茅台   1760.0  1769.99  1747.75  1769.99   \n",
      "...           ...      ...    ...      ...      ...      ...      ...   \n",
      "10062  1998-05-04  '000858  五 粮 液    59.02    59.02     55.0     55.1   \n",
      "10063  1998-04-30  '000858  五 粮 液    53.65     54.2     53.2     53.3   \n",
      "10064  1998-04-29  '000858  五 粮 液     53.3    54.98     52.9    54.97   \n",
      "10065  1998-04-28  '000858  五 粮 液    54.19     56.5     53.6     54.0   \n",
      "10066  1998-04-27  '000858  五 粮 液    53.57     57.0    29.77    29.77   \n",
      "\n",
      "           前收盘     涨跌额      涨跌幅      换手率       成交量           成交金额  \\\n",
      "0       1695.0   -28.2  -1.6637   0.1787   2244407   3756765108.0   \n",
      "1      1670.52   24.48   1.4654   0.3757   4720140   7853673241.0   \n",
      "2       1725.1  -54.58  -3.1639   0.5069   6367985  10683350187.0   \n",
      "3       1760.0   -34.9   -1.983   0.1792   2251598   3916457762.0   \n",
      "4       1766.0    -6.0  -0.3398   0.1657   2082087   3654872009.0   \n",
      "...        ...     ...      ...      ...       ...            ...   \n",
      "10062    53.65    5.37  10.0093   6.8347   4920974   285312925.33   \n",
      "10063     53.3    0.35   0.6567   3.3135   2385686   127942178.11   \n",
      "10064    54.19   -0.89  -1.6424   4.7128   3393230   181927515.95   \n",
      "10065    53.57    0.62   1.1574    9.397   6765827    371571836.1   \n",
      "10066      0.0    None     None  47.4487  34163076  1846204586.12   \n",
      "\n",
      "                   总市值             流通市值  \n",
      "0      2093830493040.0  2093830493040.0  \n",
      "1      2129255271000.0  2129255271000.0  \n",
      "2      2098503548860.0  2098503548860.0  \n",
      "3      2167066824780.0  2167066824780.0  \n",
      "4      2210908128000.0  2210908128000.0  \n",
      "...                ...              ...  \n",
      "10062    18886400000.0     4249440000.0  \n",
      "10063    17168000000.0     3862800000.0  \n",
      "10064    17056000000.0     3837600000.0  \n",
      "10065    17340800000.0     3901680000.0  \n",
      "10066    17142400000.0     3857040000.0  \n",
      "\n",
      "[10067 rows x 15 columns]\n",
      "              日期     股票代码     名称      收盘价     最高价     最低价     开盘价     前收盘  \\\n",
      "2     2020-09-17  '600519   贵州茅台  1670.52  1700.0  1658.0  1700.0  1725.1   \n",
      "4632  2020-09-17  '000858  五 粮 液   222.65   226.0   218.9  222.06  226.02   \n",
      "\n",
      "         涨跌额      涨跌幅     换手率       成交量           成交金额              总市值  \\\n",
      "2     -54.58  -3.1639  0.5069   6367985  10683350187.0  2098503548860.0   \n",
      "4632   -3.37   -1.491  0.6007  22801632  5066620919.79   864240022313.0   \n",
      "\n",
      "                 流通市值  \n",
      "2     2098503548860.0  \n",
      "4632   845171990208.0  \n"
     ]
    }
   ],
   "source": [
    "if __name__ =='__main__':\n",
    "    main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "file = CsvFile(csv_file_list[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "test = Solutions(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "show_list = test.get_df_head_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['日期',\n",
       " '股票代码',\n",
       " '名称',\n",
       " '收盘价',\n",
       " '最高价',\n",
       " '最低价',\n",
       " '开盘价',\n",
       " '前收盘',\n",
       " '涨跌额',\n",
       " '涨跌幅',\n",
       " '换手率',\n",
       " '成交量',\n",
       " '成交金额',\n",
       " '总市值',\n",
       " '流通市值']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "show_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>最高价</th>\n",
       "      <th>最低价</th>\n",
       "      <th>开盘价</th>\n",
       "      <th>前收盘</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>换手率</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-09-17</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>1700.0</td>\n",
       "      <td>1658.0</td>\n",
       "      <td>1700.0</td>\n",
       "      <td>1725.1</td>\n",
       "      <td>-54.58</td>\n",
       "      <td>-3.1639</td>\n",
       "      <td>0.5069</td>\n",
       "      <td>6367985</td>\n",
       "      <td>1.068335e+10</td>\n",
       "      <td>2.098504e+12</td>\n",
       "      <td>2.098504e+12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           日期     股票代码    名称      收盘价     最高价     最低价     开盘价     前收盘     涨跌额  \\\n",
       "2  2020-09-17  '600519  贵州茅台  1670.52  1700.0  1658.0  1700.0  1725.1  -54.58   \n",
       "\n",
       "       涨跌幅     换手率      成交量          成交金额           总市值          流通市值  \n",
       "2  -3.1639  0.5069  6367985  1.068335e+10  2.098504e+12  2.098504e+12  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.search_equal('日期', '2020-09-17', show_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>最高价</th>\n",
       "      <th>最低价</th>\n",
       "      <th>开盘价</th>\n",
       "      <th>前收盘</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>换手率</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-09-21</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1666.80</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1666.66</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>-28.2</td>\n",
       "      <td>-1.6637</td>\n",
       "      <td>0.1787</td>\n",
       "      <td>2244407</td>\n",
       "      <td>3.756765e+09</td>\n",
       "      <td>2.093830e+12</td>\n",
       "      <td>2.093830e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-09-18</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>1635.01</td>\n",
       "      <td>1665.00</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>24.48</td>\n",
       "      <td>1.4654</td>\n",
       "      <td>0.3757</td>\n",
       "      <td>4720140</td>\n",
       "      <td>7.853673e+09</td>\n",
       "      <td>2.129255e+12</td>\n",
       "      <td>2.129255e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-09-17</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>1700.00</td>\n",
       "      <td>1658.00</td>\n",
       "      <td>1700.00</td>\n",
       "      <td>1725.10</td>\n",
       "      <td>-54.58</td>\n",
       "      <td>-3.1639</td>\n",
       "      <td>0.5069</td>\n",
       "      <td>6367985</td>\n",
       "      <td>1.068335e+10</td>\n",
       "      <td>2.098504e+12</td>\n",
       "      <td>2.098504e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-09-16</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1725.10</td>\n",
       "      <td>1764.81</td>\n",
       "      <td>1719.00</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>-34.9</td>\n",
       "      <td>-1.983</td>\n",
       "      <td>0.1792</td>\n",
       "      <td>2251598</td>\n",
       "      <td>3.916458e+09</td>\n",
       "      <td>2.167067e+12</td>\n",
       "      <td>2.167067e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-09-15</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1747.75</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1766.00</td>\n",
       "      <td>-6.0</td>\n",
       "      <td>-0.3398</td>\n",
       "      <td>0.1657</td>\n",
       "      <td>2082087</td>\n",
       "      <td>3.654872e+09</td>\n",
       "      <td>2.210908e+12</td>\n",
       "      <td>2.210908e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3086</th>\n",
       "      <td>2008-01-16</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>222.84</td>\n",
       "      <td>227.00</td>\n",
       "      <td>222.00</td>\n",
       "      <td>226.80</td>\n",
       "      <td>228.36</td>\n",
       "      <td>-5.52</td>\n",
       "      <td>-2.4172</td>\n",
       "      <td>0.5496</td>\n",
       "      <td>2241908</td>\n",
       "      <td>5.022369e+08</td>\n",
       "      <td>2.103164e+11</td>\n",
       "      <td>9.090334e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3087</th>\n",
       "      <td>2008-01-15</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>228.36</td>\n",
       "      <td>230.55</td>\n",
       "      <td>224.40</td>\n",
       "      <td>224.40</td>\n",
       "      <td>224.12</td>\n",
       "      <td>4.24</td>\n",
       "      <td>1.8918</td>\n",
       "      <td>0.5222</td>\n",
       "      <td>2130322</td>\n",
       "      <td>4.861456e+08</td>\n",
       "      <td>2.155262e+11</td>\n",
       "      <td>9.315512e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3088</th>\n",
       "      <td>2008-01-14</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>224.12</td>\n",
       "      <td>228.60</td>\n",
       "      <td>218.50</td>\n",
       "      <td>225.00</td>\n",
       "      <td>216.02</td>\n",
       "      <td>8.1</td>\n",
       "      <td>3.7497</td>\n",
       "      <td>1.0523</td>\n",
       "      <td>4292507</td>\n",
       "      <td>9.598822e+08</td>\n",
       "      <td>2.115245e+11</td>\n",
       "      <td>9.142549e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3097</th>\n",
       "      <td>2007-12-28</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>230.00</td>\n",
       "      <td>230.10</td>\n",
       "      <td>217.77</td>\n",
       "      <td>221.60</td>\n",
       "      <td>224.85</td>\n",
       "      <td>5.15</td>\n",
       "      <td>2.2904</td>\n",
       "      <td>0.6528</td>\n",
       "      <td>2662799</td>\n",
       "      <td>6.004460e+08</td>\n",
       "      <td>2.170740e+11</td>\n",
       "      <td>9.382412e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3098</th>\n",
       "      <td>2007-12-27</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>224.85</td>\n",
       "      <td>225.30</td>\n",
       "      <td>217.20</td>\n",
       "      <td>222.00</td>\n",
       "      <td>222.01</td>\n",
       "      <td>2.84</td>\n",
       "      <td>1.2792</td>\n",
       "      <td>0.5370</td>\n",
       "      <td>2190698</td>\n",
       "      <td>4.858990e+08</td>\n",
       "      <td>2.122134e+11</td>\n",
       "      <td>9.172328e+10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1317 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期     股票代码    名称      收盘价      最高价      最低价      开盘价      前收盘  \\\n",
       "0     2020-09-21  '600519  贵州茅台  1666.80  1692.76  1666.66  1692.76  1695.00   \n",
       "1     2020-09-18  '600519  贵州茅台  1695.00  1695.00  1635.01  1665.00  1670.52   \n",
       "2     2020-09-17  '600519  贵州茅台  1670.52  1700.00  1658.00  1700.00  1725.10   \n",
       "3     2020-09-16  '600519  贵州茅台  1725.10  1764.81  1719.00  1760.00  1760.00   \n",
       "4     2020-09-15  '600519  贵州茅台  1760.00  1769.99  1747.75  1769.99  1766.00   \n",
       "...          ...      ...   ...      ...      ...      ...      ...      ...   \n",
       "3086  2008-01-16  '600519  贵州茅台   222.84   227.00   222.00   226.80   228.36   \n",
       "3087  2008-01-15  '600519  贵州茅台   228.36   230.55   224.40   224.40   224.12   \n",
       "3088  2008-01-14  '600519  贵州茅台   224.12   228.60   218.50   225.00   216.02   \n",
       "3097  2007-12-28  '600519  贵州茅台   230.00   230.10   217.77   221.60   224.85   \n",
       "3098  2007-12-27  '600519  贵州茅台   224.85   225.30   217.20   222.00   222.01   \n",
       "\n",
       "         涨跌额      涨跌幅     换手率      成交量          成交金额           总市值  \\\n",
       "0      -28.2  -1.6637  0.1787  2244407  3.756765e+09  2.093830e+12   \n",
       "1      24.48   1.4654  0.3757  4720140  7.853673e+09  2.129255e+12   \n",
       "2     -54.58  -3.1639  0.5069  6367985  1.068335e+10  2.098504e+12   \n",
       "3      -34.9   -1.983  0.1792  2251598  3.916458e+09  2.167067e+12   \n",
       "4       -6.0  -0.3398  0.1657  2082087  3.654872e+09  2.210908e+12   \n",
       "...      ...      ...     ...      ...           ...           ...   \n",
       "3086   -5.52  -2.4172  0.5496  2241908  5.022369e+08  2.103164e+11   \n",
       "3087    4.24   1.8918  0.5222  2130322  4.861456e+08  2.155262e+11   \n",
       "3088     8.1   3.7497  1.0523  4292507  9.598822e+08  2.115245e+11   \n",
       "3097    5.15   2.2904  0.6528  2662799  6.004460e+08  2.170740e+11   \n",
       "3098    2.84   1.2792  0.5370  2190698  4.858990e+08  2.122134e+11   \n",
       "\n",
       "              流通市值  \n",
       "0     2.093830e+12  \n",
       "1     2.129255e+12  \n",
       "2     2.098504e+12  \n",
       "3     2.167067e+12  \n",
       "4     2.210908e+12  \n",
       "...            ...  \n",
       "3086  9.090334e+10  \n",
       "3087  9.315512e+10  \n",
       "3088  9.142549e+10  \n",
       "3097  9.382412e+10  \n",
       "3098  9.172328e+10  \n",
       "\n",
       "[1317 rows x 15 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.search_cmp('收盘价', 222.65, show_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>最高价</th>\n",
       "      <th>最低价</th>\n",
       "      <th>开盘价</th>\n",
       "      <th>前收盘</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>换手率</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2020-09-08</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>221.93</td>\n",
       "      <td>229.35</td>\n",
       "      <td>217.60</td>\n",
       "      <td>227.14</td>\n",
       "      <td>226.89</td>\n",
       "      <td>-4.96</td>\n",
       "      <td>-2.1861</td>\n",
       "      <td>0.9407</td>\n",
       "      <td>35708526</td>\n",
       "      <td>7.906065e+09</td>\n",
       "      <td>8.614453e+11</td>\n",
       "      <td>8.424389e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2020-09-04</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>230.22</td>\n",
       "      <td>234.00</td>\n",
       "      <td>226.27</td>\n",
       "      <td>234.00</td>\n",
       "      <td>238.64</td>\n",
       "      <td>-8.42</td>\n",
       "      <td>-3.5283</td>\n",
       "      <td>0.9771</td>\n",
       "      <td>37092062</td>\n",
       "      <td>8.495154e+09</td>\n",
       "      <td>8.936238e+11</td>\n",
       "      <td>8.739075e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2020-07-28</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>214.00</td>\n",
       "      <td>216.94</td>\n",
       "      <td>204.67</td>\n",
       "      <td>205.89</td>\n",
       "      <td>204.10</td>\n",
       "      <td>9.9</td>\n",
       "      <td>4.8506</td>\n",
       "      <td>1.0129</td>\n",
       "      <td>38449712</td>\n",
       "      <td>8.143034e+09</td>\n",
       "      <td>8.306641e+11</td>\n",
       "      <td>8.123369e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2020-07-24</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>201.39</td>\n",
       "      <td>208.95</td>\n",
       "      <td>198.00</td>\n",
       "      <td>208.00</td>\n",
       "      <td>210.07</td>\n",
       "      <td>-8.68</td>\n",
       "      <td>-4.132</td>\n",
       "      <td>1.0679</td>\n",
       "      <td>40538626</td>\n",
       "      <td>8.233915e+09</td>\n",
       "      <td>7.817170e+11</td>\n",
       "      <td>7.644697e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2020-07-20</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>201.68</td>\n",
       "      <td>208.50</td>\n",
       "      <td>191.01</td>\n",
       "      <td>205.50</td>\n",
       "      <td>205.39</td>\n",
       "      <td>-3.71</td>\n",
       "      <td>-1.8063</td>\n",
       "      <td>1.1668</td>\n",
       "      <td>44290656</td>\n",
       "      <td>8.808311e+09</td>\n",
       "      <td>7.828427e+11</td>\n",
       "      <td>7.655706e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2020-07-17</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>205.39</td>\n",
       "      <td>209.70</td>\n",
       "      <td>195.00</td>\n",
       "      <td>195.00</td>\n",
       "      <td>201.56</td>\n",
       "      <td>3.83</td>\n",
       "      <td>1.9002</td>\n",
       "      <td>1.3956</td>\n",
       "      <td>52976677</td>\n",
       "      <td>1.078587e+10</td>\n",
       "      <td>7.972435e+11</td>\n",
       "      <td>7.796536e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2020-07-16</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>201.56</td>\n",
       "      <td>221.05</td>\n",
       "      <td>201.56</td>\n",
       "      <td>221.00</td>\n",
       "      <td>223.95</td>\n",
       "      <td>-22.39</td>\n",
       "      <td>-9.9978</td>\n",
       "      <td>1.8592</td>\n",
       "      <td>70573669</td>\n",
       "      <td>1.481795e+10</td>\n",
       "      <td>7.823769e+11</td>\n",
       "      <td>7.651151e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2020-07-15</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>223.95</td>\n",
       "      <td>226.00</td>\n",
       "      <td>217.60</td>\n",
       "      <td>219.00</td>\n",
       "      <td>220.90</td>\n",
       "      <td>3.05</td>\n",
       "      <td>1.3807</td>\n",
       "      <td>0.9792</td>\n",
       "      <td>37169954</td>\n",
       "      <td>8.289624e+09</td>\n",
       "      <td>8.692861e+11</td>\n",
       "      <td>8.501067e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>220.90</td>\n",
       "      <td>225.33</td>\n",
       "      <td>212.03</td>\n",
       "      <td>218.30</td>\n",
       "      <td>218.20</td>\n",
       "      <td>2.7</td>\n",
       "      <td>1.2374</td>\n",
       "      <td>1.1558</td>\n",
       "      <td>43873308</td>\n",
       "      <td>9.589877e+09</td>\n",
       "      <td>8.574472e+11</td>\n",
       "      <td>8.385290e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>218.20</td>\n",
       "      <td>225.00</td>\n",
       "      <td>207.00</td>\n",
       "      <td>207.00</td>\n",
       "      <td>207.00</td>\n",
       "      <td>11.2</td>\n",
       "      <td>5.4106</td>\n",
       "      <td>1.2877</td>\n",
       "      <td>48880722</td>\n",
       "      <td>1.064870e+10</td>\n",
       "      <td>8.469669e+11</td>\n",
       "      <td>8.282799e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>158</th>\n",
       "      <td>2020-02-04</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>114.50</td>\n",
       "      <td>120.00</td>\n",
       "      <td>109.00</td>\n",
       "      <td>109.00</td>\n",
       "      <td>113.54</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.8455</td>\n",
       "      <td>1.8710</td>\n",
       "      <td>71021426</td>\n",
       "      <td>8.017646e+09</td>\n",
       "      <td>4.444441e+11</td>\n",
       "      <td>4.346382e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>249</th>\n",
       "      <td>2019-09-11</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>129.26</td>\n",
       "      <td>135.60</td>\n",
       "      <td>128.68</td>\n",
       "      <td>135.00</td>\n",
       "      <td>137.25</td>\n",
       "      <td>-7.99</td>\n",
       "      <td>-5.8215</td>\n",
       "      <td>1.8501</td>\n",
       "      <td>70230982</td>\n",
       "      <td>9.220352e+09</td>\n",
       "      <td>5.017367e+11</td>\n",
       "      <td>4.906667e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>2019-07-03</td>\n",
       "      <td>'000858</td>\n",
       "      <td>五 粮 液</td>\n",
       "      <td>123.91</td>\n",
       "      <td>130.29</td>\n",
       "      <td>122.14</td>\n",
       "      <td>127.00</td>\n",
       "      <td>128.00</td>\n",
       "      <td>-4.09</td>\n",
       "      <td>-3.1953</td>\n",
       "      <td>1.8821</td>\n",
       "      <td>71443386</td>\n",
       "      <td>9.012423e+09</td>\n",
       "      <td>4.809700e+11</td>\n",
       "      <td>4.703582e+11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             日期     股票代码     名称     收盘价     最高价     最低价     开盘价     前收盘  \\\n",
       "9    2020-09-08  '000858  五 粮 液  221.93  229.35  217.60  227.14  226.89   \n",
       "11   2020-09-04  '000858  五 粮 液  230.22  234.00  226.27  234.00  238.64   \n",
       "39   2020-07-28  '000858  五 粮 液  214.00  216.94  204.67  205.89  204.10   \n",
       "41   2020-07-24  '000858  五 粮 液  201.39  208.95  198.00  208.00  210.07   \n",
       "45   2020-07-20  '000858  五 粮 液  201.68  208.50  191.01  205.50  205.39   \n",
       "46   2020-07-17  '000858  五 粮 液  205.39  209.70  195.00  195.00  201.56   \n",
       "47   2020-07-16  '000858  五 粮 液  201.56  221.05  201.56  221.00  223.95   \n",
       "48   2020-07-15  '000858  五 粮 液  223.95  226.00  217.60  219.00  220.90   \n",
       "49   2020-07-14  '000858  五 粮 液  220.90  225.33  212.03  218.30  218.20   \n",
       "50   2020-07-13  '000858  五 粮 液  218.20  225.00  207.00  207.00  207.00   \n",
       "158  2020-02-04  '000858  五 粮 液  114.50  120.00  109.00  109.00  113.54   \n",
       "249  2019-09-11  '000858  五 粮 液  129.26  135.60  128.68  135.00  137.25   \n",
       "299  2019-07-03  '000858  五 粮 液  123.91  130.29  122.14  127.00  128.00   \n",
       "\n",
       "        涨跌额      涨跌幅     换手率       成交量          成交金额           总市值  \\\n",
       "9     -4.96  -2.1861  0.9407  35708526  7.906065e+09  8.614453e+11   \n",
       "11    -8.42  -3.5283  0.9771  37092062  8.495154e+09  8.936238e+11   \n",
       "39      9.9   4.8506  1.0129  38449712  8.143034e+09  8.306641e+11   \n",
       "41    -8.68   -4.132  1.0679  40538626  8.233915e+09  7.817170e+11   \n",
       "45    -3.71  -1.8063  1.1668  44290656  8.808311e+09  7.828427e+11   \n",
       "46     3.83   1.9002  1.3956  52976677  1.078587e+10  7.972435e+11   \n",
       "47   -22.39  -9.9978  1.8592  70573669  1.481795e+10  7.823769e+11   \n",
       "48     3.05   1.3807  0.9792  37169954  8.289624e+09  8.692861e+11   \n",
       "49      2.7   1.2374  1.1558  43873308  9.589877e+09  8.574472e+11   \n",
       "50     11.2   5.4106  1.2877  48880722  1.064870e+10  8.469669e+11   \n",
       "158    0.96   0.8455  1.8710  71021426  8.017646e+09  4.444441e+11   \n",
       "249   -7.99  -5.8215  1.8501  70230982  9.220352e+09  5.017367e+11   \n",
       "299   -4.09  -3.1953  1.8821  71443386  9.012423e+09  4.809700e+11   \n",
       "\n",
       "             流通市值  \n",
       "9    8.424389e+11  \n",
       "11   8.739075e+11  \n",
       "39   8.123369e+11  \n",
       "41   7.644697e+11  \n",
       "45   7.655706e+11  \n",
       "46   7.796536e+11  \n",
       "47   7.651151e+11  \n",
       "48   8.501067e+11  \n",
       "49   8.385290e+11  \n",
       "50   8.282799e+11  \n",
       "158  4.346382e+11  \n",
       "249  4.906667e+11  \n",
       "299  4.703582e+11  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.search_cmp('成交金额', 7853673241, show_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/excel/python_program/data/lab2/data/test'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csv_file_list[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "------------------------------\n",
    "\n",
    "------------------------------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "date = input()\n",
    "dates = pd.to_datetime(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.loc[\n",
    "    (df[head[0]]==dates),\n",
    "     [head[0],head[1],head[2],\n",
    "      head[3],head[4],head[5],\n",
    "      head[6]\n",
    "     ]\n",
    "    ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "class Solutions:\n",
    "    '''\n",
    "        csv文件处理\n",
    "    '''\n",
    "    def __init__(self, CsvFile):\n",
    "        '''\n",
    "            初始化函数，\n",
    "            属性： CsvFile： CsvFile对象\n",
    "        '''\n",
    "        self.file_path =  CsvFile\n",
    "    \n",
    "        \n",
    "    def get_idx(self, flag, lists):\n",
    "        '''\n",
    "            @brief：返回 flag 在lists第一次出现的下标\n",
    "            @param: flag: 待寻找的元素\n",
    "                    lists:集合\n",
    "        '''\n",
    "        idx = 0\n",
    "        while idx<len(temp) and temp[idx]!=char:\n",
    "            idx+=1\n",
    "        return idx\n",
    "    \n",
    "    def get_last_index(self, flag, lists):\n",
    "        '''\n",
    "            获取 flag 在 lists 最后一次出现的下标\n",
    "            思路： 反转字符串后， 寻找第一次出现的下标\n",
    "        '''\n",
    "        temp = strs[::-1]  # 反转字符串\n",
    "        idx = get_idx(self, flag, temp)\n",
    "        return (len(temp)-1-idx)\n",
    "    \n",
    "    def get_id_name(self):\n",
    "        begin_char = '/'\n",
    "        end_char = '.'\n",
    "        begin_index = get_last_index(self.file_path, \n",
    "                                          begin_char) + 1\n",
    "        end_index = get_last_index(self.file_path,\n",
    "                                        end_char)\n",
    "        return self.file_path[begin_index, end_index]\n",
    "    \n",
    "    \n",
    "    def get_df(self):\n",
    "        file = pd.read_csv(file_path,encoding='gb18030')\n",
    "        df = pd.DataFrame(data)\n",
    "        return df\n",
    "    \n",
    "    def get_df_head_list(self):\n",
    "        df = self.get_df()\n",
    "        head_list = df.columns.values.tolist()\n",
    "        return head_list\n",
    "    \n",
    "    def search(self, head_idx, val, show_head_list):\n",
    "        '''\n",
    "        i.选择一只股票，显示此股票在某个输入的日期的当日数据。\n",
    "        '''\n",
    "        df_head_list = self.get_df_head_list()\n",
    "        head = df_head_list[head_idx]\n",
    "        return df.loc[ (df[head] == val), \n",
    "                show_head_list]\n",
    "\n",
    "file = CsvFile(csv_file_list[0])\n",
    "\n",
    "test = Lab2(file)\n",
    "\n",
    "show_list = test.get_df_head_list()\n",
    "\n",
    "show_list\n",
    "\n",
    "test.search(3, 222.65, show_list)\n",
    "\n",
    "csv_file_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "csv_path = os.getcwd()+'/data/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "path_file_list =  os.listdir(csv_path)\n",
    "csv_file_list = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "path_file_list =['test']+path_file_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "for files in path_file_list:\n",
    "    file_path = os.path.join(csv_path, files)\n",
    "    csv_file_list.append(file_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/excel/python_program/data/lab2/data/test',\n",
       " '/home/excel/python_program/data/lab2/data/600519.csv',\n",
       " '/home/excel/python_program/data/lab2/data/000858.csv']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csv_file_list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 目前已知csv文件名就是股票代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'get_file_list' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-7-6deaeec3e92b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_file_list\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcsv_path\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m: name 'get_file_list' is not defined"
     ]
    }
   ],
   "source": [
    "path = get_file_list(csv_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'path' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-7-a95a5317f960>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mdf_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mfiles\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m     \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfiles\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'gb18030'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0mdf_list\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'path' is not defined"
     ]
    }
   ],
   "source": [
    "df_list = []\n",
    "for files in path:\n",
    "    data = pd.read_csv(files,encoding='gb18030')\n",
    "    df = pd.DataFrame(data)\n",
    "    df_list.append(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>最高价</th>\n",
       "      <th>最低价</th>\n",
       "      <th>开盘价</th>\n",
       "      <th>前收盘</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>换手率</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-09-21</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1666.80</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1666.66</td>\n",
       "      <td>1692.76</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>-28.2</td>\n",
       "      <td>-1.6637</td>\n",
       "      <td>0.1787</td>\n",
       "      <td>2244407</td>\n",
       "      <td>3.756765e+09</td>\n",
       "      <td>2.093830e+12</td>\n",
       "      <td>2.093830e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-09-18</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>1695.00</td>\n",
       "      <td>1635.01</td>\n",
       "      <td>1665.00</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>24.48</td>\n",
       "      <td>1.4654</td>\n",
       "      <td>0.3757</td>\n",
       "      <td>4720140</td>\n",
       "      <td>7.853673e+09</td>\n",
       "      <td>2.129255e+12</td>\n",
       "      <td>2.129255e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-09-17</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1670.52</td>\n",
       "      <td>1700.00</td>\n",
       "      <td>1658.00</td>\n",
       "      <td>1700.00</td>\n",
       "      <td>1725.10</td>\n",
       "      <td>-54.58</td>\n",
       "      <td>-3.1639</td>\n",
       "      <td>0.5069</td>\n",
       "      <td>6367985</td>\n",
       "      <td>1.068335e+10</td>\n",
       "      <td>2.098504e+12</td>\n",
       "      <td>2.098504e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-09-16</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1725.10</td>\n",
       "      <td>1764.81</td>\n",
       "      <td>1719.00</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>-34.9</td>\n",
       "      <td>-1.983</td>\n",
       "      <td>0.1792</td>\n",
       "      <td>2251598</td>\n",
       "      <td>3.916458e+09</td>\n",
       "      <td>2.167067e+12</td>\n",
       "      <td>2.167067e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-09-15</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1747.75</td>\n",
       "      <td>1769.99</td>\n",
       "      <td>1766.00</td>\n",
       "      <td>-6.0</td>\n",
       "      <td>-0.3398</td>\n",
       "      <td>0.1657</td>\n",
       "      <td>2082087</td>\n",
       "      <td>3.654872e+09</td>\n",
       "      <td>2.210908e+12</td>\n",
       "      <td>2.210908e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4624</th>\n",
       "      <td>2001-08-31</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>37.01</td>\n",
       "      <td>37.62</td>\n",
       "      <td>36.80</td>\n",
       "      <td>37.15</td>\n",
       "      <td>37.10</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.2426</td>\n",
       "      <td>3.2492</td>\n",
       "      <td>2323148</td>\n",
       "      <td>8.623124e+07</td>\n",
       "      <td>9.252500e+09</td>\n",
       "      <td>2.646215e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4625</th>\n",
       "      <td>2001-08-30</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>37.10</td>\n",
       "      <td>37.51</td>\n",
       "      <td>36.00</td>\n",
       "      <td>36.28</td>\n",
       "      <td>36.38</td>\n",
       "      <td>0.72</td>\n",
       "      <td>1.9791</td>\n",
       "      <td>6.7151</td>\n",
       "      <td>4801306</td>\n",
       "      <td>1.775586e+08</td>\n",
       "      <td>9.275000e+09</td>\n",
       "      <td>2.652650e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4626</th>\n",
       "      <td>2001-08-29</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>36.38</td>\n",
       "      <td>37.00</td>\n",
       "      <td>36.10</td>\n",
       "      <td>36.98</td>\n",
       "      <td>36.86</td>\n",
       "      <td>-0.48</td>\n",
       "      <td>-1.3022</td>\n",
       "      <td>7.4479</td>\n",
       "      <td>5325275</td>\n",
       "      <td>1.946896e+08</td>\n",
       "      <td>9.095000e+09</td>\n",
       "      <td>2.601170e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4627</th>\n",
       "      <td>2001-08-28</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>36.86</td>\n",
       "      <td>37.00</td>\n",
       "      <td>34.61</td>\n",
       "      <td>34.99</td>\n",
       "      <td>35.55</td>\n",
       "      <td>1.31</td>\n",
       "      <td>3.685</td>\n",
       "      <td>18.1326</td>\n",
       "      <td>12964779</td>\n",
       "      <td>4.634631e+08</td>\n",
       "      <td>9.215000e+09</td>\n",
       "      <td>2.635490e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4628</th>\n",
       "      <td>2001-08-27</td>\n",
       "      <td>'600519</td>\n",
       "      <td>贵州茅台</td>\n",
       "      <td>35.55</td>\n",
       "      <td>37.78</td>\n",
       "      <td>32.85</td>\n",
       "      <td>34.51</td>\n",
       "      <td>31.39</td>\n",
       "      <td>4.16</td>\n",
       "      <td>13.2526</td>\n",
       "      <td>56.8277</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1.410347e+09</td>\n",
       "      <td>8.887500e+09</td>\n",
       "      <td>2.541825e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4629 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期     股票代码    名称      收盘价      最高价      最低价      开盘价      前收盘  \\\n",
       "0     2020-09-21  '600519  贵州茅台  1666.80  1692.76  1666.66  1692.76  1695.00   \n",
       "1     2020-09-18  '600519  贵州茅台  1695.00  1695.00  1635.01  1665.00  1670.52   \n",
       "2     2020-09-17  '600519  贵州茅台  1670.52  1700.00  1658.00  1700.00  1725.10   \n",
       "3     2020-09-16  '600519  贵州茅台  1725.10  1764.81  1719.00  1760.00  1760.00   \n",
       "4     2020-09-15  '600519  贵州茅台  1760.00  1769.99  1747.75  1769.99  1766.00   \n",
       "...          ...      ...   ...      ...      ...      ...      ...      ...   \n",
       "4624  2001-08-31  '600519  贵州茅台    37.01    37.62    36.80    37.15    37.10   \n",
       "4625  2001-08-30  '600519  贵州茅台    37.10    37.51    36.00    36.28    36.38   \n",
       "4626  2001-08-29  '600519  贵州茅台    36.38    37.00    36.10    36.98    36.86   \n",
       "4627  2001-08-28  '600519  贵州茅台    36.86    37.00    34.61    34.99    35.55   \n",
       "4628  2001-08-27  '600519  贵州茅台    35.55    37.78    32.85    34.51    31.39   \n",
       "\n",
       "         涨跌额      涨跌幅      换手率       成交量          成交金额           总市值  \\\n",
       "0      -28.2  -1.6637   0.1787   2244407  3.756765e+09  2.093830e+12   \n",
       "1      24.48   1.4654   0.3757   4720140  7.853673e+09  2.129255e+12   \n",
       "2     -54.58  -3.1639   0.5069   6367985  1.068335e+10  2.098504e+12   \n",
       "3      -34.9   -1.983   0.1792   2251598  3.916458e+09  2.167067e+12   \n",
       "4       -6.0  -0.3398   0.1657   2082087  3.654872e+09  2.210908e+12   \n",
       "...      ...      ...      ...       ...           ...           ...   \n",
       "4624   -0.09  -0.2426   3.2492   2323148  8.623124e+07  9.252500e+09   \n",
       "4625    0.72   1.9791   6.7151   4801306  1.775586e+08  9.275000e+09   \n",
       "4626   -0.48  -1.3022   7.4479   5325275  1.946896e+08  9.095000e+09   \n",
       "4627    1.31    3.685  18.1326  12964779  4.634631e+08  9.215000e+09   \n",
       "4628    4.16  13.2526  56.8277  40631800  1.410347e+09  8.887500e+09   \n",
       "\n",
       "              流通市值  \n",
       "0     2.093830e+12  \n",
       "1     2.129255e+12  \n",
       "2     2.098504e+12  \n",
       "3     2.167067e+12  \n",
       "4     2.210908e+12  \n",
       "...            ...  \n",
       "4624  2.646215e+09  \n",
       "4625  2.652650e+09  \n",
       "4626  2.601170e+09  \n",
       "4627  2.635490e+09  \n",
       "4628  2.541825e+09  \n",
       "\n",
       "[4629 rows x 15 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_list[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
